<!DOCTYPE html><html><head><meta charset=utf-8><title>H3DU.TextureLoader</title></head><body><h1> H3DU.TextureLoader</h1><p><a href='index.html'>Back to documentation index.</a></p><a name='H3DU.TextureLoader'></a>
<h3> H3DU.TextureLoader()</h3>An object that caches loaded textures and uploads them
to WebGL contexts.<h3> Methods</h3><ul><li><a href='#H3DU.TextureLoader_dispose'>dispose</a><br>Disposes all resources used by this texture loader.<li><a href='#H3DU.TextureLoader_getTexture'>getTexture</a><br>Gets an already loaded texture by name from this texture loader.<li><a href='#H3DU.TextureLoader_loadAndMapTexture'>loadAndMapTexture</a><br>Loads the texture referred to in an array of URLs and
uploads its texture data to a WebGL context.<li><a href='#H3DU.TextureLoader_loadAndMapTexturesAll'>loadAndMapTexturesAll</a><br>Loads one or more textures by their URL and uploads their data to a WebGL context.<li><a href='#H3DU.TextureLoader_loadCubeMap'>loadCubeMap</a><br>Loads the textures described in a cube map.<li><a href='#H3DU.TextureLoader_loadTexture'>loadTexture</a><br>Loads a texture by its URL and stores its data.<li><a href='#H3DU.TextureLoader_loadTexturesAll'>loadTexturesAll</a><br>Loads the textures referred to in an array of URLs and
stores their texture data.</ul><a name='H3DU.TextureLoader_dispose'></a>
<h3> H3DU.TextureLoader#dispose()</h3>Disposes all resources used by this texture loader.<h4> Return Value</h4>This method doesn't return a value. (Type: void)<a name='H3DU.TextureLoader_getTexture'></a>
<h3> H3DU.TextureLoader#getTexture(name)</h3>Gets an already loaded texture by name from this texture loader.<h4> Parameters</h4><ul><li><code>name</code> (Type: string)<br>The name of the texture, usually its file name.</ul><h4> Return Value</h4>The texture with the given name, or null
if it isn't fully loaded or doesn't exist. (Type: <a href="H3DU.Texture.html">H3DU.Texture</a>)<a name='H3DU.TextureLoader_loadAndMapTexture'></a>
<h3> H3DU.TextureLoader#loadAndMapTexture(texture, context)</h3>Loads the texture referred to in an array of URLs and
uploads its texture data to a WebGL context.<h4> Parameters</h4><ul><li><code>texture</code> (Type: String | <a href="H3DU.TextureInfo.html">H3DU.TextureInfo</a> | <a href="H3DU.Texture.html">H3DU.Texture</a>)<br>An object described in H3DU.TextureLoader.loadTexture.<li><code>context</code> (Type: WebGLRenderingContext | WebGL2RenderingContext | Object)<br>A WebGL context to associate with this scene, or an object, such as <a href="H3DU.Scene3D.html">H3DU.Scene3D</a>, that implements a no-argument <code>getContext</code> method that returns a WebGL context.</ul><h4> Return Value</h4>A promise that resolves when
the texture is loaded successfully (the result will be an H3DU.Texture object)
and is rejected when an error occurs. (Type: <a href="Promise.html">Promise</a>.&lt;<a href="H3DU.Texture.html">H3DU.Texture</a>>)<a name='H3DU.TextureLoader_loadAndMapTexturesAll'></a>
<h3> H3DU.TextureLoader#loadAndMapTexturesAll(textures, context, [resolve], [reject])</h3>Loads one or more textures by their URL and uploads their data to a WebGL context.<h4> Parameters</h4><ul><li><code>textures</code> (Type: Array.&lt;(String|<a href="H3DU.TextureInfo.html">H3DU.TextureInfo</a>|<a href="H3DU.Texture.html">H3DU.Texture</a>)>)<br>An array of objects described in H3DU.TextureLoader.loadTexture.<li><code>context</code> (Type: WebGLRenderingContext | WebGL2RenderingContext | Object)<br>A WebGL context to associate with this scene, or an object, such as <a href="H3DU.Scene3D.html">H3DU.Scene3D</a>, that implements a no-argument <code>getContext</code> method that returns a WebGL context.<li><code>resolve</code> (Type: function) (optional)<br>A function called as each individual texture is loaded and its promise resolves.<li><code>reject</code> (Type: function) (optional)<br>A function called as each individual texture is loaded and its promise is rejected.</ul><h4> Return Value</h4>A promise as described in
<a href="H3DU.html#H3DU.getPromiseResultsAll">H3DU.getPromiseResultsAll</a>. If the promise
resolves, each item in the resulting array will be a loaded
<a href="H3DU.Texture.html">H3DU.Texture</a> object. (Type: <a href="Promise.html">Promise</a>.&lt;<a href="H3DU.Texture.html">H3DU.Texture</a>>)<a name='H3DU.TextureLoader_loadCubeMap'></a>
<h3> H3DU.TextureLoader#loadCubeMap(texturesOrCubeMap, [resolve], [reject])</h3>Loads the textures described in a cube map.<h4> Parameters</h4><ul><li><code>texturesOrCubeMap</code> (Type: Array.&lt;(String|<a href="H3DU.TextureInfo.html">H3DU.TextureInfo</a>|<a href="H3DU.Texture.html">H3DU.Texture</a>)> | <a href="H3DU.CubeMap.html">H3DU.CubeMap</a>)<br>Either an array of objects described in H3DU.TextureLoader.loadTexture or a cube map object.<li><code>resolve</code> (Type: function) (optional)<br>A function called as each individual texture is loaded and its promise resolves.<li><code>reject</code> (Type: function) (optional)<br>A function called as each individual texture is loaded and its promise is rejected.</ul><h4> Return Value</h4>A promise that resolves when
all textures used by the cube map are loaded successfully
(the result will be an H3DU.CubeMap object)
and is rejected when an error occurs. (Type: <a href="Promise.html">Promise</a>.&lt;<a href="H3DU.Texture.html">H3DU.Texture</a>>)<a name='H3DU.TextureLoader_loadTexture'></a>
<h3> H3DU.TextureLoader#loadTexture(texture)</h3>Loads a texture by its URL and stores its data.<h4> Parameters</h4><ul><li><code>texture</code> (Type: String | <a href="H3DU.TextureInfo.html">H3DU.TextureInfo</a> | <a href="H3DU.Texture.html">H3DU.Texture</a>)<br>An <a href="H3DU.Texture.html">H3DU.Texture</a> object, an <a href="H3DU.TextureInfo.html">H3DU.TextureInfo</a> object, or a string with the URL of the texture data.<p> Images with a TGA extension that use the RGBA or grayscale format are supported. Images supported by the browser will be loaded via the JavaScript DOM's Image class.</ul><h4> Return Value</h4>A promise that resolves when the texture
is fully loaded. If it resolves, the result will be an H3DU.Texture object. (Type: <a href="Promise.html">Promise</a>.&lt;<a href="H3DU.Texture.html">H3DU.Texture</a>>)<a name='H3DU.TextureLoader_loadTexturesAll'></a>
<h3> H3DU.TextureLoader#loadTexturesAll(textures, [resolve], [reject])</h3>Loads the textures referred to in an array of URLs and
stores their texture data.<h4> Parameters</h4><ul><li><code>textures</code> (Type: Array.&lt;(String|<a href="H3DU.TextureInfo.html">H3DU.TextureInfo</a>|<a href="H3DU.Texture.html">H3DU.Texture</a>)>)<br>An array of objects described in H3DU.TextureLoader.loadTexture.<li><code>resolve</code> (Type: function) (optional)<br>A function called as each individual texture is loaded and its promise resolves.<li><code>reject</code> (Type: function) (optional)<br>A function called as each individual texture is loaded and its promise is rejected.</ul><h4> Return Value</h4>A promise as described in
<a href="H3DU.html#H3DU.getPromiseResultsAll">H3DU.getPromiseResultsAll</a>. If the promise
resolves, each item in the resulting array will be a loaded
<a href="H3DU.Texture.html">H3DU.Texture</a> object. (Type: <a href="Promise.html">Promise</a>.&lt;<a href="H3DU.Texture.html">H3DU.Texture</a>>)<p><a href='index.html'>Back to documentation index.</a></p></body></html>
